﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace WpfApp1.Model
{
    public class AgeToColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            SolidColorBrush background = Brushes.Black;
            if(value!=null&&(int.TryParse(value.ToString(),out int age)))
             {
                if (age < 30)
                {
                    background = Brushes.AliceBlue;
                }
                else if (age < 60)
                {
                    background = Brushes.Red;
                }
                else
                {
                    background = Brushes.Brown;
                }               
            }
            return background;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
